<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="keyword" placeholder="请输入姓名">
        <ul>
            <li v-for="(item,index) in filterPersons" :key="item.id">{{item.name}}--{{item.age}}</li></li>
        </ul>
    </div>
</body>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                msg: 'hello world',
                keyword:'',
                persons:[
                    {
                        id:1,
                        name: '张三',
                        age: 18
                    },
                    {
                        id:2,
                        name: '李四',
                        age: 19
                    },
                    {
                        id:3,
                        name: '王五',
                        age: 20
                    }
                ]
            },
            computed:{
                filterPersons(){
                    return this.persons.filter((per)=>{
                        return per.name.indexOf(this.keyword)!==-1;
                    });
                }
            }
        })
    </script>
</html>